# read file
handle = open("container.py", "r")
data = handle.read()
print(data)
handle.close()

handle = open("container.py", "r")
for line in handle:
    print(line)
handle.close()

# write file
handle = open("test.txt", "w")
handle.write("This is a test!")
handle.close()

# with

try:
    file_handler = open("test.txt")
    for line in file_handler:
        print(line)
except IOError:
    print("An IOError has occurred!")
finally:
    file_handler.close()

with open("test.txt") as file_handler:
    for line in file_handler:
        print(line)
